﻿using System;
using System.IO; 
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class imageteporarty : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        if (Session["SELECTED_LANGUAGE"] != null)
        {
            string current_language = Session["SELECTED_LANGUAGE"].ToString();

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(current_language);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(current_language);
      }
        else
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;         
        }
        
        base.InitializeCulture();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Label2.Text = "Logged in as: " + Context.User.Identity.Name;
        
        logoutButton.Visible = true;
        logoutButton.Text = "[Logout]";
                
        if (Request.Params["lang"] != null)
        {
            string current_language = Request.Params["lang"].ToString();
        }
                
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        cmpEntry new_company = new cmpEntry();

        new_company.cmpName = TextBox1.Text;
        new_company.cmpAddress = TextBox2.Text;
        new_company.cmpEmail = TextBox3.Text;
        new_company.cmpCountry = TextBox4.Text;
        new_company.cmpCity = TextBox7.Text;
        new_company.cmpPhone = TextBox8.Text;
        new_company.cmpFax = TextBox9.Text;
        new_company.cmpWebsite = TextBox10.Text; 
        new_company.cmpDescription = TextBox5.Text;
        new_company.cmpKeywords = TextBox6.Text;
        new_company.app_path = Request.PhysicalApplicationPath;
        new_company.cmpLogofile = UploadFileInput.PostedFile; 
        new_company.current_user = Context.User.Identity.Name; 
        
        new_company.cmpPost();
                
        Response.Redirect("viewDetails.aspx?CompId=" + new_company.cmpID.ToString()); 
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }

    protected void btnLogout_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Response.Redirect("Default.aspx"); 
    }
    protected void Link_EN_Click(object sender, EventArgs e)
    {
        Session.Add("SELECTED_LANGUAGE", "en-US");
        Response.Redirect(Request.Url.AbsoluteUri); 
    }
    protected void Link_RU_Click(object sender, EventArgs e)
    {
        Session.Add("SELECTED_LANGUAGE", "ru-RU");
        Response.Redirect(Request.Url.AbsoluteUri); 
    }

    [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    
    public static string[] GetCompletionList(string prefixText, int count, string contextKey)
    {
        dbProcessor my_db = new dbProcessor();
        
        return my_db.select_cities(count, prefixText); 
    }
}